package main.component.infodialog;

import java.io.IOException;
import java.net.URL;

import javafx.scene.control.Alert;
import javafx.scene.control.DialogPane;
import javafx.stage.Stage;

public class InfoDialogControl extends Alert{


	private static final String CSS_FILE_PATH = "main/component/infodialog/InfoDialog.css";
	
		
	public InfoDialogControl(AlertType alertType, String title, String info, Stage stage) {
		super(alertType);
		loadCssFile(this.getDialogPane(), CSS_FILE_PATH);
		this.setContentText(info);
		if(title != null){
			this.setTitle(title);
			this.setHeaderText(title);
		}
		if(stage != null) {
			this.initOwner(stage);
		}
	}
	
	public void showDialog() throws IOException {
		this.show();
	}
	
	/**
	 * ????scene????CSS???
	 * @param dialogPane ???????scene????
	 * @param cssFilePath css???·??
	 */
	private void loadCssFile(DialogPane dialogPane, String cssFilePath) {
		URL cssUrl = this.getClass().getClassLoader().getResource(cssFilePath);
		dialogPane.getStylesheets().add(cssUrl.toExternalForm());
	}


	
}
